package com.roy.springboot.security.oauth2.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer;
import org.springframework.security.oauth2.config.annotation.web.configuration.ResourceServerConfigurerAdapter;

/**
 * Created by elloxxn on 12/14/2017.
 */
@Configuration
@EnableResourceServer
public class ResourceServerConfig extends ResourceServerConfigurerAdapter {

    @Override
    public void configure(HttpSecurity http) throws Exception {
        http.headers().frameOptions().disable().and()
                .authorizeRequests()
                .antMatchers("/","/home","/register","/login","/h2-console","/beans").permitAll()
//                .antMatchers("/s-role1").access("hasAuthority('ROLE_ANON')")
//                .antMatchers("/s-role2").access("hasRole('ACTUATOR')")
                .antMatchers("/private/**").authenticated()
                .and()
                .formLogin().permitAll();
    }

}
